package com.yangkunhong.controller;

import com.yangkunhong.pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 使用注解配置映射关系
 */
@WebServlet(urlPatterns = "/IndexServlet001")
public class IndexServlet001 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("控制器收到GET请求");
        //获取当前的回话数据
        User user_info = (User) req.getSession().getAttribute("USER_INFO");
        System.out.println(user_info);
        //显示前台首页

        req.getRequestDispatcher("/frontend/index.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("控制器收到POST请求");
    }
}
